package com.stox.charting.ui.swing.model;

import java.util.Calendar;

import com.stox.resources.i18n.MessageSource;

public enum BarSpan {
	
	SECONDLY(MessageSource.getMessage("Secondly"), Calendar.SECOND),
	MINUTELY(MessageSource.getMessage("Minutely"), Calendar.MINUTE), 
	HOURLY(MessageSource.getMessage("Hourly"), Calendar.HOUR), 
	DAILY(MessageSource.getMessage("Daily"), Calendar.DATE), 
	WEEKLY(MessageSource.getMessage("Weekly"), Calendar.WEEK_OF_YEAR), 
	MONTHLY(MessageSource.getMessage("Monthly"), Calendar.MONTH), 
	QUARTERLY(MessageSource.getMessage("Quarterly"), Calendar.MONTH), 
	YEARLY(MessageSource.getMessage("Yearly"), Calendar.YEAR);
	
	private final String text;
	private final int unit;
	
	private BarSpan(String text, int unit) {
		this.text = text;
		this.unit = unit;
	}
	
	public String getText() {
		return text;
	}
	
	public int getUnit() {
		return unit;
	}
	
	public static void alter(){
		
	}
	
	public static BarSpan value(int ordinal){
		BarSpan[] values = values();
		for(BarSpan timeUnit : values){
			if(ordinal == timeUnit.ordinal()){
				return timeUnit;
			}
		}
		return null;
	}
	
	@Override
	public String toString() {
		return getText();
	}
}
